package com.candy.databasedocuments.service;

import com.candy.databasedocuments.entity.DatabaseConfig;
import com.candy.databasedocuments.entity.DbAttr;
import com.candy.databasedocuments.entity.Table;
import com.candy.databasedocuments.utils.JdbcConnectUtil;

import javax.annotation.Resource;
import java.sql.Connection;
import java.util.List;

/**
 * @author suYanLong
 * @version 1.0
 * @date 2023/7/5 14:43
 * @Description 数据库链接抽象类
 */
public abstract class AbstractDatabaseConnect implements DatabaseConnect {

    @Resource
    public DatabaseConfig databaseConfig;

    @Override
    public void getConnectInfo(DatabaseConfig databaseConfig) {

    }

    @Override
    public Connection connectDatabase(DatabaseConfig databaseConfig) throws Exception {
        DbAttr dbAttr = databaseConfig.getDbAttr();
        return JdbcConnectUtil.getConnect(dbAttr.getDriver(), dbAttr.getUrl(), dbAttr.getUsername(), dbAttr.getPassword());
    }

    @Override
    public List<Table> getTableBaseInfoList(Connection connection) {
        return null;
    }

    public String getDateMateName(Connection connection) {
        return null;
    }

    public List<Table> getDateMateTableName(Connection connection, String dateMateName) {
        return null;
    }

    public List<Table> selectTablesFields(Connection connection, List<Table> tableNames) {
        return null;
    }

    public List<Table> selectTablesKeys(Connection connection, List<Table> tableNames) {
        return tableNames;
    }

}
